import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

@Entity("market_stall_trades")
@ManualTimestamp()
export class StallTradeEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Index()
  @Column("int", { name: "sell_role_id", comment: "卖家角色ID" })
  sellRoleId!: number;

  @Index()
  @Column("int", { name: "buy_role_id", comment: "买家角色ID" })
  buyRoleId!: number;

  @Column("int", { name: "thing_id", comment: "物品ID/装备唯一ID等" })
  thingId!: number;

  @Column("tinyint", {
    name: "thing_type",
    comment: "类型，同 items.thing_type",
  })
  thingType!: number;

  @Column("varchar", { length: 100, name: "thing_name", comment: "物品名" })
  thingName!: string;

  @Column("int", { name: "count", comment: "数量", default: 1 })
  count!: number;

  @Column("int", { name: "money", comment: "成交额(银两)", default: 0 })
  money!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
